<template>
  <section class="main">
    <div class="title">
      <span>基本信息</span>
      <div>
        <el-button icon="el-icon-edit" @click="modifyData"></el-button>
        <el-button icon="el-icon-refresh" @click="refresh"></el-button>
      </div>
    </div>
    <div class="container container1">
      <div class="itemBox">
        <div class="line">
          <div>服务商级别</div>
          <!-- <div>{{merchantinfo.merchantName}}</div> -->
          <div>{{merchantinfo.typeName}}</div>
        </div>
        <div class="line">
          <div>服务商编号</div>
          <div>{{merchantinfo.agentcode}}</div>
        </div>
        <div class="line">
          <div>服务商名称</div>
          <div>{{merchantinfo.agentname}}</div>
        </div>
        <div class="line">
          <div>开户账号</div>
          <div>{{merchantinfo.cardnum}}</div>
        </div>
      </div>
      <div class="itemBox">
        <div class="line">
          <div>联系人</div>
          <div>{{merchantinfo.contacts}}</div>
        </div>
        <div class="line">
          <div>联系人手机号</div>
          <div>{{merchantinfo.phone}}</div>
        </div>
        <div class="line">
          <div>联系人邮箱</div>
          <div>{{merchantinfo.email}}</div>
        </div>
        <div class="line">
          <div>开户名</div>
          <div>{{merchantinfo.cardname}}</div>
        </div>
      </div>
    </div>
    <!-- 支付通道 -->
    <div class="title">
      <span>支付&通道</span>
      <div>
        <!-- <el-button type="primary">同步渠道</el-button> -->
        <el-button type="primary" @click="Channeldeploys" v-show="type !== 2">配置渠道</el-button>
        <el-button icon="el-icon-refresh" @click="refresh"></el-button>
      </div>
    </div>
    <div class="container container1">
      <div class="tableBox">
        <el-table
          ref="multipleTable"
          :data="merchantarr"
          tooltip-effect="dark"
          style="width: 100%"
          stripe
          :header-cell-style="tableHeaderColor"
        >
          <!-- <el-table-column type="selection"></el-table-column> -->
          <el-table-column type="index" align="center" label="序号"></el-table-column>
          <el-table-column prop="channelName" align="center" label="通道名称"></el-table-column>
          <el-table-column prop="wxProfitRate" align="center" label="微信成本(万分比)">
            <template slot-scope="scope">
              <div>{{(scope.row.wxProfitRate)}}</div>
            </template>
          </el-table-column>
          <el-table-column prop="aliProfitRate" align="center" label="支付宝成本(万分比)">
            <template slot-scope="scope">
              <div>{{(scope.row.aliProfitRate)}}</div>
            </template>
          </el-table-column>
          <el-table-column align="center" label="云闪付成本">
            <template slot-scope="scope">
              <div>{{scope.row.uniProfitRate}}</div>
            </template>
          </el-table-column>
          <el-table-column align="center" label="银行卡成本">
            <template slot-scope="scope">
              <div>信用卡成本万分比：{{scope.row.creditcardProfitRate}}</div>
              <div>储蓄卡成本万分比：{{scope.row.debitcardProfitRate}}</div>
              <div>封顶费用（元）：{{scope.row.debitcardTopFee/100}}</div>
            </template>
          </el-table-column>
          <el-table-column align="center" label="翼支付成本">
            <template slot-scope="scope">
              <div>{{scope.row.bestpayProfitRate}}</div>
            </template>
          </el-table-column>
          <el-table-column align="center" label="数字人民币成本">
            <template slot-scope="scope">
              <div>{{scope.row.ecnyProfitRate}}</div>
            </template>
          </el-table-column>
          <el-table-column align="center" label="龙支付成本">
            <template slot-scope="scope">
              <div>{{scope.row.longpayProfitRate}}</div>
            </template>
          </el-table-column>
          <el-table-column align="center" label="结算比例">
            <template slot-scope="scope">
              <div>{{scope.row.percent}}%</div>
            </template>
          </el-table-column>

          <el-table-column fixed="right" align="center" label="操作" width="200">
            <template slot-scope="scope">
              <el-button type="text" size="small" @click="costs(scope.row)">修改成本</el-button>
              <!-- <el-button type="text" size="small" @click="accounts()">配置结算比例</el-button> -->
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
    <!-- 优惠券通道 -->
    <div class="title">
      <span>优惠券通道</span>
      <div>
        <el-button type="primary" v-show="type !== 2" @click="showChannelConfig">配置通道</el-button>
        <el-button icon="el-icon-refresh" @click="refresh"></el-button>
      </div>
    </div>
    <div class="container container1">
      <div class="cBox" v-for="(item, index) in configList" :key="index">
                <div :title="item.reviewedReason" class="channelitem" style="height:200px;">
                    <div class="line">{{item.channelName}}</div>
                    <div class="line">
                        <i class="el-icon-s-shop" style="font-size:50px" v-if="item.img === ''"></i>
                        <img :src="item.img" alt="" v-else style="margin-right:0px;width:45px;">
                    </div>
                </div>
            </div>
     
    </div>
    <div class="title" v-if="alterService.typeName == 1">
      <span>二级服务商</span>
      <div>
        <el-button icon="el-icon-refresh" @click="refresh"></el-button>
      </div>
    </div>
    <div class="container container1" v-if="alterService.typeName == 1">
      <div class="tableBox">
        <el-table
          ref="multipleTable"
          :data="merchantarr2"
          tooltip-effect="dark"
          style="width: 100%"
          stripe
          :header-cell-style="tableHeaderColor"
        > 
          <el-table-column type="index" align="center" label="序号"></el-table-column>
        
          <el-table-column prop="agentname" align="center" label="服务商名称"></el-table-column>
          <el-table-column prop="agentcode" align="center" label="编号"></el-table-column>
          <el-table-column prop="contacts" align="center" label="联系人"></el-table-column>
          <el-table-column prop="phone" align="center" label="手机号"></el-table-column>
          <el-table-column prop="createtime" fixed="right" align="center" label="创建时间" width="200"></el-table-column>
        </el-table>
      </div>
    </div>
    <div class="title">
      <span>标签</span>
      <div>
        <el-button type="primary" @click="popuptag">添加标签</el-button>
      </div>
    </div>
    <div class="container container1">
        <el-tag class="el_tag"
            v-for="item in adm_tag"
            closable
             @close="handleClose(item.key)"
            :key="item.label"
            effect="plain">
            {{ item.label }}
        </el-tag>
        <el-tag class="el_tag"
            v-for="item in cw_tag"
            closable
             @close="handleClose(item.key)"
             type="success"
            :key="item.label"
            effect="plain">
            {{ item.label }}
        </el-tag>
        <el-tag class="el_tag"
            v-for="item in fws_tag"
            closable
             @close="handleClose(item.key)"
             type="warning"
            :key="item.label"
            effect="plain">
            {{ item.label }}
        </el-tag>
    </div>
   
    <!-- 渠道配置 -->
    <el-dialog v-dialogDrag title="渠道配置" :visible.sync="Channeldeploy" width="50%" :close-on-click-modal='false'>
        <el-transfer class="customTable" v-model="value1" :data="data1" :titles="['未拥有', '已拥有']"></el-transfer>
      <div style="width:100%;text-align:right;margin-top: 20px;">
        <el-button type="primary" @click="Channeldeploy = false">取消</el-button>
        <el-button type="primary" @click='configchannel'>确定</el-button>
      </div>
    </el-dialog>
    <!-- 修改成本 -->
    <el-dialog v-dialogDrag title="修改费率" :visible.sync="cost" width="35%" :close-on-click-modal='false'>
      <el-form :model="rate" status-icon label-width="110px" class="demo-dynamic">
        <el-form-item label="微信">
          <el-select width="100" v-model="rate.wxProfitRate" placeholder="请选择微信成本">
            <el-option v-for="(value,index) in wxList" :key="index" :label="value.rate" :value="value.rate"></el-option>
          </el-select> <span>（万分比）</span>
        </el-form-item>
        <el-form-item label="支付宝">
          <el-select width="100" v-model="rate.aliProfitRate" placeholder="请选择支付宝成本">
            <el-option v-for="(value,index) in aliList" :key="index" :label="value.rate" :value="value.rate"></el-option>
          </el-select> <span>（万分比）</span>
        </el-form-item>
        <el-form-item label="云闪付">
          <el-select width="100" v-model="rate.uniProfitRate" placeholder="请选择云闪付成本">
            <el-option v-for="(value,index) in uniList" :key="index" :label="value.rate" :value="value.rate"></el-option>
          </el-select> <span>（万分比）</span>
        </el-form-item>
        <el-form-item label="翼支付">
          <el-select width="100" v-model="rate.bestpayProfitRate" placeholder="请选择翼支付成本">
            <el-option v-for="(value,index) in uniList" :key="index" :label="value.rate" :value="value.rate"></el-option>
          </el-select> <span>（万分比）</span>
        </el-form-item>
        <el-form-item label="数字人民币">
          <el-select width="100" v-model="rate.ecnyProfitRate" placeholder="请选择数字人民币成本">
            <el-option v-for="(value,index) in uniList" :key="index" :label="value.rate" :value="value.rate"></el-option>
          </el-select> <span>（万分比）</span>
        </el-form-item>
        <el-form-item label="龙支付">
          <el-select width="100" v-model="rate.longpayProfitRate" placeholder="请选择龙支付成本">
            <el-option v-for="(value,index) in uniList" :key="index" :label="value.rate" :value="value.rate"></el-option>
          </el-select> <span>（万分比）</span>
        </el-form-item>
        <el-form-item label="信用卡">
          <el-input type="text" v-model="rate.creditcardProfitRate" placeholder="请输入信用卡成本（万分比）" oninput = "value=value.replace(/[^\d{1,}\.\d{1,}|\d{1,}]/g,'')"></el-input><span>（万分比）</span>
        </el-form-item>
        <el-form-item label="储蓄卡">
          <el-input type="text" v-model="rate.debitcardProfitRate" placeholder="请输入储蓄卡成本（万分比）" oninput = "value=value.replace(/[^\d{1,}\.\d{1,}|\d{1,}]/g,'')"></el-input><span>（万分比）</span>
        </el-form-item>
        <el-form-item label="封顶">
          <el-input type="text" :maxlength='5' v-model="rate.debitcardTopFee" placeholder="请输入储蓄卡封顶金额（元）" oninput = "value=value.replace(/[^\d{1,}\.\d{1,}|\d{1,}]/g,'')"></el-input><span>（元）</span>
        </el-form-item>
        <el-form-item label="结算比例">
          <el-input type="text" maxlength="3" min="0" v-model="rate.percent" placeholder="请输入结算比例(输入0-100之前的整数即可)" oninput = "value=value.replace(/[^\d{1,}\d{1,}|\d{1,}]/g,'')"></el-input><span>（%）</span>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="cost = false">取消</el-button>
        <el-button type="primary" @click="submitRates()">确定</el-button>
      </span>
    </el-dialog>
   
    <!-- 修改服务商 -->
    <el-dialog v-dialogDrag title="修改服务商" :visible.sync="visible1" width="45%" :close-on-click-modal='false'>
        <el-form
          :model="alterService"
          status-icon
          label-width="150px"
          class="demo-dynamic"
        >
          <el-form-item :required="true" label="服务商级别：" >
           <el-select width="100" v-model="alterService.typeName" placeholder="请选择" :disabled="true">
              <el-option keys="1" label="一级服务商" :value="1"></el-option>
              <el-option keys="2" label="二级服务商" :value="2"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item :required="true" label="服务商编号：">
            <el-input type="text" v-model.trim="alterService.agentcode" :disabled="true" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item :required="true" label="服务商名称：">
            <el-input type="text" v-model.trim="alterService.agentname" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item :required="true" label="联系人：">
            <el-input type="text" v-model.trim="alterService.contacts" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item :required="true" label="联系人手机号：">
            <el-input type="text" v-model.trim="alterService.phone" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item :required="true" label="联系人邮箱：">
            <el-input type="text" v-model.trim="alterService.email" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item :required="true" label="开户账号：">
            <el-input type="text" v-model.trim="alterService.cardnum" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item :required="true" label="开户名：">
            <el-input type="text" v-model.trim="alterService.cardname" autocomplete="off"></el-input>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button @click="visible1 = false">取消</el-button>
          <!-- @click="visible = false" -->
          <el-button type="primary" @click="alterService1()">确定</el-button>
        </span>
      </el-dialog>
    <br>
    <!-- 标签配置 -->
    <el-dialog v-dialogDrag title="添加标签" :visible.sync="Channeldeploy1" width="45%" :close-on-click-modal='false'>
      <el-transfer
       class="customTable"
       v-model="usedTags" 
       :data="unUsedTags"
       :titles="['未选标签', '已选择标签']" 
       filterable
       filter-placeholder="请输入关键词"
       >
       <!--  -->
      </el-transfer>
      <div style="width:100%;text-align:right;margin-top:30px;">
        <el-button type="primary" @click="Channeldeploy1 = false">取消</el-button>
        <el-button type="primary" @click='addLabel()'>确定</el-button>
      </div>
    </el-dialog>
    <!-- 优惠券通道配置 -->
    <el-dialog v-dialogDrag title="配置通道" :visible.sync="channelConfigVisible" width="45%" :close-on-click-modal='false'>
      <el-transfer 
        class="customTable"
       v-model="configInfo" 
       :data="unConfigInfo"
       :titles="['未配置通道', '已配置通道']" 
       filterable
       filter-placeholder="请输入关键词"
       >
       <!--  -->
      </el-transfer>
      <div style="width:100%;text-align:right;margin-top:30px;">
        <el-button type="primary" @click="channelConfigVisible = false">取消</el-button>
        <el-button type="primary" @click='addChannelConfig()'>确定</el-button>
      </div>
    </el-dialog>
    <br>
  </section>
</template>

<script>
import { institutionChannelsConfig, getInstitutionChannels, merchantdetails, channel, getServiceData, updateServiceProviders, getPaymentList, getConfigureChannels, postConfigureChannels, getRateList, postSubmitRates, agentRateConfirm, getLastService, getdimensionTagList, getSelectTagsByRole, postDimensionTagSave, postDimensionTagRemove } from "@/api/api";
export default {
  // name: "baseform",
  data() {
    return {
      routerDataId: '',
      parentid:'',//二级服务的上级服务商
      type:'',
      merchantinfo: {
        typeName:'',
        agentcode:'',
        agentname:'',
        cardnum:'',
        contacts:'',
        phone:'',
        email:'',
        cardname:''
      },
      vdata:[],
      //修改服务商
      visible1: false,
      alterService:{
        typeName:'',
        agentcode:'',
        agentname:'',
        cardnum:'',
        contacts:'',
        phone:'',
        email:'',
        cardname:''
      },
      state: "1",
      note: "",
      data1: [],
      Channeldeploy: false,
      cost: false,
      account: false,
      wxList:[],//微信费率
      aliList:[],//支付宝费率
      uniList:[],
      rate: { //修改费率
        id:'',
        wxProfitRate: "",//微信
        aliProfitRate:'',//支付宝
        uniProfitRate: '', //云闪付
        creditcardProfitRate:'',//信用卡
        debitcardProfitRate:'',//储蓄卡
        debitcardTopFee:'',//封顶费用
        percent:''//结算比例
      },
      accountarr:{

      },
      value1: [],
      merchantarr: [],
      merchantarr2: [],//下属二级服务商
      adm_tag:[],//超管 运营标签
      cw_tag:[],//财务标签
      fws_tag:[],//服务商标签
      tag_color:'',//标签颜色
      Channeldeploy1: false, //添加标签穿梭框开关
      unUsedTags:[],//添加标签穿梭框 未选择的标签
      usedTags:[],//添加标签穿梭框 已选择的标签
      agentname:'',//服务商名称
      rolesId:'',
      channelConfigVisible: false,
      configList: [],
      configInfo: [],// 添加配置通道，已选择标签
      unConfigInfo: []// 添加配置通道，未选择标签
    };
  },
  created() {
    this.routerDataId = sessionStorage.getItem("serviceproviders_id")
    this.alterService.typeName = sessionStorage.getItem("serviceproviders_type")
    // console.log(this.alterService.typeName)
    // this.agentname = JSON.parse(sessionStorage.getItem("serviceproviders_agentname"))
    var aaa = sessionStorage.getItem('userInfo')
    var bbb = JSON.parse(aaa)
    this.rolesId = bbb.rolesId
    this.getRouterData()
    this.getPaymentList()
    this.getLastService()
    this.getdimensionTagList()//获取指定对象已拥有的标签
    this.getInsChannel()
  },
  mounted(){
    
  },
  
  methods: {
     //修改thead 背景色
     tableHeaderColor({ row, column, rowIndex, columnIndex }) {
      if (rowIndex === 0) {
        return 'background-color: #F0F0F0;font-weight: 500;font-size:14px;color:#000;'
      }
    },
    // 获取机构通道配置
    async getInsChannel() {
      const res = await getInstitutionChannels(this.routerDataId)
      if(res.code === 405) {
        sessionStorage.removeItem("token");
        this.$router.push("/login");
      }else{}
      if(res.code === 500) {
        if(this.alterService.typeName == 1){
          this.$message.error(res.message)
        }
      }
      this.configList = res.data.usedChannel
    },
    // 打开配置通道弹窗
    async showChannelConfig() {
      if(!this.channelConfigVisible) {
        this.configInfo = []
      }
      this.channelConfigVisible = true
      const res = await getInstitutionChannels(this.routerDataId)
      if(res.code === 405) {
        sessionStorage.removeItem("token");
        this.$router.push("/login");
      } else if (res.code === 200) {
        if(this.unConfigInfo.length === 0) {
          res.data.unUsedChannel.forEach(val => {
            this.unConfigInfo.push({key: val.id, label: val.channelName})
          })
        }
        if(this.configInfo.length === 0) {
          res.data.usedChannel.forEach(val => {
            this.configInfo.push(val.id)
          })
        }
        if(res.code === 500) {
          this.$message.error(res.message)
        }
      }
    },
    // 配置通道
    async addChannelConfig() {
      let data = this.configInfo.join(',')
      const res = await institutionChannelsConfig({
        channelIds: data
      }, this.routerDataId)
      if(res.code === 405) {
        sessionStorage.removeItem("token");
        this.$router.push("/login");
      } 
      if(res.code === 500) {
        return this.$message.error(res.message)
      } 
      if (res.code === 200) {
        this.$message.success(res.message)
        this.getInsChannel()
        this.channelConfigVisible = false
      }
    },
    // 刷新
    refresh (){
      this.$router.go(0);
    },
    getRouterData(){
      getServiceData({},this.routerDataId).then(res => {
        if(res.code == 405){
            sessionStorage. removeItem('token')
            this.$router.push('/login');
        }else{
          if(res.code == 405){
            sessionStorage. removeItem('token')
            this.$router.push('/login');
          }else if(res.code == 200){
            this.vdata = []
            this.vdata = res.data
            console.log(res.data)
            this.parentid = res.data.parentid
            this.type = res.data.type
            // this.alterService.typeName = res.data.type
            this.merchantinfo.typeName = res.data.typeName
            this.merchantinfo.agentcode = res.data.agentcode
            this.merchantinfo.agentname = res.data.agentname
            this.merchantinfo.cardnum = res.data.cardnum
            this.merchantinfo.contacts = res.data.contacts
            this.merchantinfo.phone = res.data.phone
            this.merchantinfo.email = res.data.email
            this.merchantinfo.cardname = res.data.cardname
            this.agentname = res.data.agentname
          }else if(res.code == 500){
            this.$message.error(res.message);
          }
        }
      })
    },
    //获取支付列表数据
    getPaymentList(){
      // console.log(this.alterService.typeName)
      getPaymentList({
        type:this.alterService.typeName,
        fid: this.routerDataId
      }).then(res => {
        if(res.code == 200){
          this.merchantarr = res.data
        }
      })
    },
    //获取下属二级服务商数据
    getLastService(){
      getLastService({
        parentid:this.routerDataId
      }).then(res => {
        console.log(res)
        if(res.code == 405){
          sessionStorage. removeItem('token')
          this.$router.push('/login');
        }else if(res.code ==200){
          this.merchantarr2 = res.data.rows
        }
      })
    },
    //   渠道配置
    Channeldeploys() {
      if(this.Channeldeploy === false){
        this.value1 = []
      }
      this.Channeldeploy = true;
      getConfigureChannels({},this.routerDataId).then(res => {
        if(res.code == 200){
          console.log(this.data1)
          if(this.data1.length == 0){
            for(var i = 0; i < res.data.unUsedChannel.length ; i++){
              this.data1.push({key:res.data.unUsedChannel[i].id,label:res.data.unUsedChannel[i].channelname})
            }
          } 
          if(this.value1.length == 0){
            for(var i = 0; i < res.data.usedChannel.length ;i++){
              this.value1.push(res.data.usedChannel[i].id)
            }
          }
        }
      })
      
    },
    //添加渠道配置
    configchannel(){
      console.log(this.value1)
      var data = this.value1.join(',')
      postConfigureChannels({
        channelIds: data
      },this.routerDataId).then(res => {
        if(res.code == 405){
          sessionStorage. removeItem('token')
          this.$router.push('/login');
        }else if(res.code == 200){
          this.$message({
            message: '配置成功',
            type: 'success'
          });
          this.Channeldeploy = false
          this.getRouterData()
          this.getPaymentList()
        }else if(res.code == 500){
          this.Channeldeploy = true
          this.$message.error(res.message)
        }
      })
    },
    // 修改成本
    costs(v) {
      console.log(v)
      this.cost = true;
      getRateList({
        fid: v.fid,
        channelType: v.channelType,
        type: v.type,
        payType: '400',
      }).then(res => {
        if(res.code == 200){
          // console.log(res)
          this.wxList = []
          // this.wxList = res.data
          for(var i = 0; i < res.data.length; i++){
              this.wxList.push({id: res.data[i].id,rate: (res.data[i].rate)})
          }
          // // console.log(this.wxList)
          // this.aliList = []
          // // this.aliList = res.data
          // for(var i = 0; i < res.data.length; i++){
          //     this.aliList.push({id: res.data[i].id,rate: (res.data[i].rate)})
          // }
          // this.uniList = []
          // for(var i = 0; i < res.data.length; i++){
          //     this.uniList.push({id: res.data[i].id,rate: (res.data[i].rate)})
          // }
        }else{
          this.$message.error(res.message);
        }
      })
      getRateList({
        fid: v.fid,
        channelType: v.channelType,
        type: v.type,
        payType: '300',
      }).then(res => {
        if(res.code == 200){
          this.aliList = []
          // this.aliList = res.data
          for(var i = 0; i < res.data.length; i++){
              this.aliList.push({id: res.data[i].id,rate: (res.data[i].rate)})
          }
        }else{
          this.$message.error(res.message);
        }
      })
       getRateList({
        fid: v.fid,
        channelType: v.channelType,
        type: v.type,
        payType: '600',
      }).then(res => {
        if(res.code == 200){
           this.uniList = []
          for(var i = 0; i < res.data.length; i++){
              this.uniList.push({id: res.data[i].id,rate: (res.data[i].rate)})
          }
        }else{
          this.$message.error(res.message);
        }
      })
      this.rate.id = v.id
      this.rate.wxProfitRate = v.wxProfitRate
      this.rate.aliProfitRate = v.aliProfitRate
      this.rate.uniProfitRate = v.uniProfitRate
      this.rate.creditcardProfitRate = v.creditcardProfitRate
      this.rate.debitcardProfitRate = v.debitcardProfitRate
      this.rate.debitcardTopFee = v.debitcardTopFee/100
      this.rate.percent = v.percent
      // for(var i = 0; i < this.wxList.length;i++){
      //   if(v.wxProfitRateCode == this.wxList[i].id){
      //     this.rate.wxProfitRate = this.wxList[i].id
      //   }
      // }
      // for(var i = 0; i < this.aliList.length;i++){
      //   if(v.aliProfitRateCode == this.aliList[i].id){
      //     this.rate.aliProfitRate = this.aliList[i].id
      //   }
      // }
    },
    //提交修改费率
    submitRates(){
      if(this.rate.debitcardTopFee >100 || this.rate.debitcardTopFee < 0){
        this.$message.error({
          message:"储蓄卡封顶费用范围为0~100元",
          type: 'success'
        })
        return false
      }
      // console.log(this.rate.wxProfitRate)
      console.log(this.rate.id)
      agentRateConfirm({ //提交费率前的验证
        wxProfitRate: this.rate.wxProfitRate,
        aliProfitRate: this.rate.aliProfitRate,
        uniProfitRate: this.rate.uniProfitRate,
        bestProfitRate: this.rate.bestProfitRate,
        ecnyProfitRate: this.rate.ecnyProfitRate,
        longpayProfitRate: this.rate.longpayProfitRate,
        creditcardProfitRate: this.rate.creditcardProfitRate,
        debitcardProfitRate: this.rate.debitcardProfitRate,
        debitcardTopFee: Math.round(this.rate.debitcardTopFee*100),
        percent: this.rate.percent,
      },this.rate.id).then(res => {
        if(res.code == 201){
          this.$confirm(res.message, "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
          }).then(() => {
                postSubmitRates({
                  wxProfitRate: this.rate.wxProfitRate,
                  aliProfitRate: this.rate.aliProfitRate,
                  uniProfitRate: this.rate.uniProfitRate,
                  bestProfitRate: this.rate.bestProfitRate,
                  ecnyProfitRate: this.rate.ecnyProfitRate,
                  longpayProfitRate: this.rate.longpayProfitRate,
                  creditcardProfitRate: this.rate.creditcardProfitRate,
                  debitcardProfitRate: this.rate.debitcardProfitRate,
                  debitcardTopFee: Math.round(this.rate.debitcardTopFee*100),
                  percent: this.rate.percent,
                },this.rate.id).then(res => {
                  if(res.code == 405){
                    sessionStorage. removeItem('token')
                    this.$router.push('/login');
                  }else if(res.code == 200){
                    this.$message({
                      message: '修改成功',
                      type: 'success'
                    });
                    this.cost = false
                    this.getRouterData()
                    this.getPaymentList()
                  }else{
                    this.$message.error(res.message);
                  }
                })
            })
            .catch(() => {
                this.$message({
                    type: "info",
                    message: "已取消"
                });
      });
          // this.$message.error(res.message);
          // return false
        }else if(res.code == 500){
          this.$message.error(res.message);
          return false
        }else if(res.code == 200){
          postSubmitRates({
            wxProfitRate: this.rate.wxProfitRate,
            aliProfitRate: this.rate.aliProfitRate,
            uniProfitRate: this.rate.uniProfitRate,
            creditcardProfitRate: this.rate.creditcardProfitRate,
            debitcardProfitRate: this.rate.debitcardProfitRate,
            debitcardTopFee: Math.round(this.rate.debitcardTopFee*100),
            percent: this.rate.percent,
          },this.rate.id).then(res => {
            if(res.code == 405){
              sessionStorage. removeItem('token')
              this.$router.push('/login');
            }else if(res.code == 200){
              this.$message({
                message: '修改成功',
                type: 'success'
              });
              this.cost = false
              this.getRouterData()
              this.getPaymentList()
            }else{
              this.$message.error(res.message);
            }
          })
        }
      })
      
    },
    // 配置结算比例
    accounts(){
        this.account = true;
    },
    modifyData(){
      this.visible1 = true
      this.alterService.typeName = this.vdata.type
      this.alterService.agentcode = this.vdata.agentcode
      this.alterService.agentname = this.vdata.agentname
      this.alterService.cardnum = this.vdata.cardnum
      this.alterService.contacts = this.vdata.contacts
      this.alterService.phone = this.vdata.phone
      this.alterService.email = this.vdata.email
      this.alterService.cardname = this.vdata.cardname
    },

    //修改服务商
    alterService1(){
      updateServiceProviders({
        type: this.alterService.typeName,
        parentid: this.parentid,
        agentcode: this.alterService.agentcode,
        agentname: this.alterService.agentname,
        contacts: this.alterService.contacts,
        phone: this.alterService.phone,
        email: this.alterService.email,
        cardnum: this.alterService.cardnum,
        cardname: this.alterService.cardname
      },this.routerDataId).then(res => {
        if(res.code == 405){
          sessionStorage. removeItem('token')
          this.$router.push('/login');
        }else if(res.code == 200){
          this.$message({
            message: '修改成功',
            type: 'success'
          });
          this.visible1 = false
          this.getRouterData()
        }else{
          this.$message.error(res.message);
        }
      })
    },
    //显示添加标签弹框
    popuptag(){
      if(this.Channeldeploy1 === false){
        this.usedTags = []
      }
      this.Channeldeploy1 = true
      var roleId = ''
      console.log(this.alterService.typeName)
      if(this.alterService.typeName == 1){
        roleId = 2 //如果传过来的type等于1 说明他是一级服务商 roleId就是2
      }else if(this.alterService.typeName == 2){
        roleId = 3
      }
      //获取指定对象可添加标签
      getSelectTagsByRole({
        fid: this.routerDataId,
        roleId: roleId
      }).then(res => {
        if (res.code == 405) {
            sessionStorage.removeItem("token");
            this.$router.push("/login");
        } else if(res.code == 200){
          if(this.unUsedTags.length == 0){
            for(var i = 0; i < res.data.allTags.length; i++){
              this.unUsedTags.push({key:res.data.allTags[i].id,label:res.data.allTags[i].name})
            }
          } 
          if(this.usedTags.length == 0){
            for(var i = 0; i < res.data.usedTags.length;i++){
              this.usedTags.push(res.data.usedTags[i].id)
            }
          }
        }else if(res.code == 500){
            this.$message.error(res.message);   
        }
      })
    },
    //获取指定对象已拥有的标签
    getdimensionTagList(){
      var roleId = ''
      if(this.alterService.typeName == 1){
        roleId = 2 //如果传过来的type等于1 说明他是一级服务商 roleId就是2
      }else if(this.alterService.typeName == 2){
        roleId = 3
      }
      this.adm_tag = []
      this.cw_tag = []
      this.fws_tag = []
      getdimensionTagList({
        fid: this.routerDataId,
        roleId: roleId
      }).then(res => {
        if (res.code == 405) {
            sessionStorage.removeItem("token");
            this.$router.push("/login");
        } else if(res.code == 200){
            console.log(res)
            for(var i = 0; i < res.data.length; i++){
              if(res.data[i].tagCreatorRole == 1 ||res.data[i].tagCreatorRole == 8){
                this.adm_tag.push({key:res.data[i].id,label:res.data[i].tagName})
              }else if(res.data[i].tagCreatorRole == 9){
                this.cw_tag.push({key:res.data[i].id,label:res.data[i].tagName})
              }else if(res.data[i].tagCreatorRole == 2){
                this.fws_tag.push({key:res.data[i].id,label:res.data[i].tagName})
              }
            }
            // if(this.rolesId == 2){
            //   this.adm_tag = []
            //   this.cw_tag = []
            // }
        }else if(res.code == 500){
            this.$message.error(res.message);   
        }
      })
    },
    //给指定对象添加标签
    addLabel(){
      var data = this.usedTags.join(',')
      var roleId = ''
      if(this.alterService.typeName == 1){
        roleId = 2 //如果传过来的type等于1 说明他是一级服务商 roleId就是2
      }else if(this.alterService.typeName == 2){
        roleId = 3
      }
      postDimensionTagSave({
        ids: data,
        fid: this.routerDataId,
        roleId: roleId,
        holder: this.agentname
      },this.routerDataId).then(res => {
        if(res.code == 405){
          sessionStorage. removeItem('token')
          this.$router.push('/login');
        }else if(res.code == 200){
          this.$message({
            message: '添加成功',
            type: 'success'
          });
          this.Channeldeploy1 = false
          this.getdimensionTagList()
        }else if(res.code == 500){
          this.Channeldeploy1 = true
          this.$message.error(res.message)
        }
      })
    },
    handleClose(id){
      this.$confirm(`是否确定删除该标签？`, "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
      }).then(() => {
          postDimensionTagRemove({},id).then(res =>{
            if(res.code == 405){
              sessionStorage. removeItem('token')
              this.$router.push('/login');
            }else if(res.code == 200){
              this.$message({
                message: '删除成功',
                type: 'success'
              });
              this.getdimensionTagList()
            }else if(res.code == 500){
              this.$message.error(res.message);
            }
          })
      })
      .catch(() => {
          this.$message({
              type: "info",
              message: "已取消"
          });
      });
    }
  },
};
</script>

<style scoped lang="less">
/deep/.transfer .el-dialog__body .el-transfer{
  text-align: center;
}
.title {
  background: #fff;
  padding: 10px;
  font-size: 18px;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
}
.container1 {
  width: 100%;
  display: flex;
  margin-bottom: 20px;
  box-sizing: border-box;
}
.container1 .itemBox {
  width: 50%;
}
.container1 .itemBox .line {
  width: 100%;
  display: flex;
  font-size: 14px;
  line-height: 200%;
}
.container1 .itemBox .line div:nth-child(1) {
  width: 20%;
  text-align: left;
}
.container1 .itemBox .line div:nth-child(2) {
  width: 80%;
  text-align: left;
  color: #888888;
}
.container1 {
  width: 100%;
  display: flex;
  margin-bottom: 20px;
  box-sizing: border-box;
  flex-wrap: wrap;
  .attachmentitem {
    width: 16.5%;
    text-align: center;
    margin-bottom: 20px;
    div {
      font-size: 14px;
      &:nth-child(1) {
        margin-bottom: 5px;
      }
    }
  }
}
.red {
  color: red;
}
.tableBox {
  width: 100%;
}
.el-input{
  width: 70%;
}
.el_tag{
  margin-right: 10px;
  margin-bottom: 5px;
}
.channel .cBox {
  width: 14.8%;
  margin-right: 25px;
  margin-bottom: 25px;
}
.line {
  display: flex;
  width: 100%;
  justify-content: center;
  align-items: center;
  margin: 10px 0;
  margin-top: 20px;
}
.channelitem {
  width: 227px;
  margin-right: 20px;
  margin-bottom: 20px;
  border: 1px solid #e9e9e9;
  border-radius: 8px;
  position: relative;
  padding: 20px 0;
  box-shadow: 5px 5px 5px #e9e9e9;
}
.channelitem:hover {
  transform: scale(1.1);
}

.customTable{
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>
